package com.zmn.plat.services.impl.brand;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.zmn.plat.model.entity.brand.BrandRatio;
import com.zmn.plat.model.entity.brand.BrandRatioQuery;
import com.zmn.plat.model.vo.brand.BrandRatioVo;
import com.zmn.plat.persistence.interfaces.brand.BrandRatioDAO;
import com.zmn.plat.services.interfaces.brand.BrandRatioService;

/**
 * 类描述:品牌系数管理实现类
 *
 * @author linfeng
 * @since 2019/11/21/11:20
 */
@Service
public class BrandRatioServiceImpl implements BrandRatioService {

    @Resource
    private BrandRatioDAO brandRatioDAO;

    @Override
    public List<BrandRatioVo> listPageByQuery(BrandRatioQuery query) {
        int count = brandRatioDAO.countByQuery(query);
        query.setTotalCount(count);
        return brandRatioDAO.listPageByQuery(query);
    }

    @Override
    public List<BrandRatio> listByQuery(BrandRatioQuery query) {
        return brandRatioDAO.listByQuery(query);
    }

    @Override
    @Cacheable(cacheNames = "redis1h", key = "'base:ratio:BrandRatioService:BrandRatioQuery:'+#p0", unless = "#result == null")
    public List<BrandRatio> listByQueryWithCache(BrandRatioQuery query) {
        return brandRatioDAO.listByQuery(query);
    }

    @Override
    @Cacheable(cacheNames = "redis1d", key = "'price:listForFlowByBizType:bizType:'+#p0", unless = "#result == null")
    public List<BrandRatio> listForFlowByBizType(Integer bizType) {
        return brandRatioDAO.listForFlowByBizType(bizType);
    }

    @Override
    @Cacheable(cacheNames = "redis1d", key = "'price3:listForFlow3'", unless = "#result == null")
    public List<Integer> listForFlow3() {
        return brandRatioDAO.listForFlow3();
    }

    @Override
    public Integer updateByKey(BrandRatio brandRatio) {
        return brandRatioDAO.updateByKey(brandRatio);
    }

    @Override
    public void updateToBeEffectiveRatioBatch(List<BrandRatio> updateRatioList) {
        brandRatioDAO.updateToBeEffectiveRatioBatch(updateRatioList);
    }

    @Override
    public Integer updateRatioByKeyBatch(List<BrandRatio> brandRatioList) {
        return brandRatioDAO.updateRatioByKeyBatch(brandRatioList);
    }

    @Override
    public Integer insert(BrandRatio brandRatio) {
        return brandRatioDAO.insert(brandRatio);
    }

    @Override
    public Integer insertBatch(List<BrandRatio> brandRatioList) {
        return brandRatioDAO.insertBatch(brandRatioList);
    }

    @Override
    public void deleteByBrandId(Integer brandId) {
        brandRatioDAO.deleteByBrandId(brandId);
    }

    @Override
    public void deleteByBrandIdsAndPriceType(String[] ids, Integer priceType) {
        brandRatioDAO.deleteByBrandIdsAndPriceType(ids, priceType);
    }

    @Override
    public void deleteByPrimaryKey(Integer factorId) {
        brandRatioDAO.deleteByPrimaryKey(factorId);
    }

    @Override
    public void deleteByKeys(List<Integer> ratioIds) {
        brandRatioDAO.deleteByKeys(ratioIds);
    }
}
